/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved.
 * MemCache_Hybrid is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *          http://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
*/
#ifndef MMC_META_SERVICE_PROCESS_H
#define MMC_META_SERVICE_PROCESS_H

#include "mmc_leader_election.h"
#include "mmc_configuration.h"
#include "mmc_meta_service_default.h"


namespace ock {
namespace mmc {

class MmcMetaServiceProcess {
public:
    static MmcMetaServiceProcess& getInstance()
    {
        static MmcMetaServiceProcess meta;
        return meta;
    }
    MmcMetaServiceProcess() = default;
    ~MmcMetaServiceProcess() = default;
    MmcMetaServiceProcess(const MmcMetaServiceProcess&) = delete;
    MmcMetaServiceProcess& operator=(const MmcMetaServiceProcess&) = delete;

    int MainForExecutable();
    int MainForPython();

private:
    static bool CheckIsRunning();
    int LoadConfig();
    static void RegisterSignal();
    static void SignalInterruptHandler(const int signal);
    static int InitLogger(const mmc_meta_service_config_t& options);
    void Exit();

    mmc_meta_service_config_t config_{};
    MmcMetaServiceDefault *metaService_{};
    MmcMetaServiceLeaderElection *leaderElection_{};
};

} // namespace mmc
} // namespace ock

#endif